var jsGoogleCE={map:null,mapId:"",arData:null,obForm:null,currentView:"",bPositionFixed:true,bAddPointMode:false,bAddPolyMode:false,DblClickObserver:null,__arValidKeys:["google_lat","google_lon","google_scale","PLACEMARKS","LON","LAT","TEXT"],__currentPolyLine:null,__currentPolyLineObject:null,init:function(e){if(typeof e.mapId!=="undefined"){jsGoogleCE.mapId=e.mapId}BX.loadCSS("/bitrix/components/bitrix/map.google.system/templates/.default/style.css");jsGoogleCE.map=GLOBAL_arMapObjects["system_view_edit_"+jsGoogleCE.mapId];jsGoogleCE.arData=arPositionData;jsGoogleCE.obForm=document.forms["bx_popup_form_google_map_"+jsGoogleCE.mapId];jsGoogleCE.obForm.onsubmit=jsGoogleCE.__saveChanges;google.maps.event.addListener(jsGoogleCE.map,"dragend",jsGoogleCE.__getPositionValues);google.maps.event.addListener(jsGoogleCE.map,"maptypeid_changed",jsGoogleCE.__getPositionValues);if(!jsGoogleCE.arData.google_lat||!jsGoogleCE.arData.google_lon||!jsGoogleCE.arData.google_scale){var o=jsGoogleCE.map.getCenter();jsGoogleCE.arData.google_lat=o.lat();jsGoogleCE.arData.google_lon=o.lng();jsGoogleCE.arData.google_scale=jsGoogleCE.map.getZoom();jsGoogleCE.bPositionFixed=false}else{jsGoogleCE.arData.google_scale=parseInt(jsGoogleCE.arData.google_scale);jsGoogleCE.bPositionFixed=true}jsGoogleCE.setControlValue("google_lat",jsGoogleCE.arData.google_lat);jsGoogleCE.setControlValue("google_lon",jsGoogleCE.arData.google_lon);jsGoogleCE.setControlValue("google_scale",jsGoogleCE.arData.google_scale);jsGoogleCE.currentView=BX.message("google_current_view");jsGoogleCE.setControlValue("google_view",BX.message("google_MAP_VIEW_"+jsGoogleCE.map.getMapTypeId().toUpperCase()));if(BX.browser.IsIE()){var l=new google.maps.Marker({position:new google.maps.LatLng(90,0),map:jsGoogleCE.map})}if(jsGoogleCE.arData.PLACEMARKS&&jsGoogleCE.arData.PLACEMARKS.length>0){for(var a=0,t=jsGoogleCE.arData.PLACEMARKS.length;a<t;a++){jsGoogleCE.addCustomPoint(jsGoogleCE.arData.PLACEMARKS[a],a)}}BX("bx_restore_position_"+jsGoogleCE.mapId).onclick=jsGoogleCE.restorePositionValues;BX("bx_google_map_controls_"+jsGoogleCE.mapId).style.visibility="visible";BX("bx_google_map_address_search_"+jsGoogleCE.mapId).style.visibility="visible"},__getPositionValues:function(){if(jsGoogleCE.bPositionFixed)return;var e=jsGoogleCE.map.getCenter();jsGoogleCE.arData.google_lat=e.lat();jsGoogleCE.arData.google_lon=e.lng();jsGoogleCE.arData.google_scale=jsGoogleCE.map.getZoom();jsGoogleCE.setControlValue("google_lat",jsGoogleCE.arData.google_lat);jsGoogleCE.setControlValue("google_lon",jsGoogleCE.arData.google_lon);jsGoogleCE.setControlValue("google_scale",jsGoogleCE.arData.google_scale);jsGoogleCE.currentView=jsGoogleCE.map.getMapTypeId().toUpperCase();jsGoogleCE.setControlValue("google_view",BX.message("google_MAP_VIEW_"+jsGoogleCE.currentView))},restorePositionValues:function(e){BX.PreventDefault(e);if(jsGoogleCE.currentView&&google.maps.MapTypeId[jsGoogleCE.currentView])jsGoogleCE.map.setMapTypeId(google.maps.MapTypeId[jsGoogleCE.currentView]);jsGoogleCE.map.setZoom(jsGoogleCE.arData.google_scale);jsGoogleCE.map.panTo(new google.maps.LatLng(jsGoogleCE.arData.google_lat,jsGoogleCE.arData.google_lon))},setFixedFlag:function(e){jsGoogleCE.bPositionFixed=e;if(!e)jsGoogleCE.__getPositionValues()},setControlValue:function(e,o){var l=jsGoogleCE.obForm["bx_"+e];if(null!=l)l.value=o;var a=BX("bx_"+e+"_value");if(null!=a)a.innerHTML=o},__updatePointPosition:function(){if(null==this.BX_PLACEMARK_INDEX)return;var e=this.getPosition();jsGoogleCE.arData.PLACEMARKS[this.BX_PLACEMARK_INDEX].LON=e.lng();jsGoogleCE.arData.PLACEMARKS[this.BX_PLACEMARK_INDEX].LAT=e.lat()},addPoint:function(){if(jsGoogleCE.bAddPointMode){jsGoogleCE.bAddPointMode=false;jsGoogleCE.map.disableDoubleClickZoom=false;BX("bx_google_addpoint_link_"+jsGoogleCE.mapId).style.display="block";BX("bx_google_addpoint_message"+jsGoogleCE.mapId).style.display="none";if(jsGoogleCE.DblClickObserver)google.maps.event.removeListener(jsGoogleCE.DblClickObserver)}else{jsGoogleCE.bAddPointMode=true;jsGoogleCE.map.disableDoubleClickZoom=true;document.getElementById("bx_google_addpoint_link_"+jsGoogleCE.mapId).style.display="none";document.getElementById("bx_google_addpoint_message_"+jsGoogleCE.mapId).style.display="block";jsGoogleCE.DblClickObserver=google.maps.event.addListener(jsGoogleCE.map,"dblclick",jsGoogleCE.__addPoint)}},__openBalloon:function(e){if(null==e.infowin){e.infowin=new google.maps.InfoWindow({content:""})}e.infowin.setContent('<textarea onblur="jsGoogleCE.__updatePointView(this, \'blur\')" onkeyup="jsGoogleCE.__updatePointView(this, \'keyup\')" id="BX_PLACEMARK_TEXT_'+e.BX_PLACEMARK_INDEX+'" rows="4" style="resize:none;">'+BX.util.htmlspecialchars(jsGoogleCE.arData.PLACEMARKS[e.BX_PLACEMARK_INDEX].TEXT)+"</textarea>");e.infowin.open(jsGoogleCE.map,e);setTimeout(function(){try{BX("BX_PLACEMARK_TEXT_"+e.BX_PLACEMARK_INDEX).focus()}catch(e){}},500)},__pointClick:function(){jsGoogleCE.__openBalloon(this)},__createPlaceMark:function(e,o){if(null==jsGoogleCE.arData.PLACEMARKS)jsGoogleCE.arData.PLACEMARKS=[];if(null==o){o=jsGoogleCE.arData.PLACEMARKS.length;jsGoogleCE.arData.PLACEMARKS[o]={TEXT:e.TEXT}}if(null!=e.POS){jsGoogleCE.arData.PLACEMARKS[o].LON=e.POS.lng();jsGoogleCE.arData.PLACEMARKS[o].LAT=e.POS.lat()}else{jsGoogleCE.arData.PLACEMARKS[o].LAT=e.LAT;jsGoogleCE.arData.PLACEMARKS[o].LON=e.LON}var l=jsGoogleCE.__createPointView();l.id="BX_PLACEMARK_"+o;var a=new google.maps.LatLng(jsGoogleCE.arData.PLACEMARKS[o].LAT,jsGoogleCE.arData.PLACEMARKS[o].LON);var t="";if(e.TEXT.length>0){var s=e.TEXT.indexOf("\n");t=s<=0?e.TEXT:e.TEXT.substring(0,s);t=BX.util.htmlspecialchars(t)}l.BXPlacemark=new google.maps.Marker({position:a,map:jsGoogleCE.map,draggable:true});l.BXPlacemark.BX_PLACEMARK_INDEX=o;l.BXPlacemark.BXTEXT="";if(null!=e.TEXT&&e.TEXT.length>0)l.BXPlacemark.BXTEXT=e.TEXT.replace(/\n/g,"<br />");google.maps.event.addListener(l.BXPlacemark,"click",jsGoogleCE.__pointClick);google.maps.event.addListener(l.BXPlacemark,"dragend",jsGoogleCE.__updatePointPosition);jsGoogleCE.__updatePointViewText(l,t?t:BX.message("google_noname"));return l.BXPlacemark},addCustomPoint:function(e,o){jsGoogleCE.__createPlaceMark({TEXT:e.TEXT,LON:e.LON,LAT:e.LAT},o)},__addPoint:function(e){if(!jsGoogleCE.bAddPointMode)return;jsGoogleCE.__openBalloon(jsGoogleCE.__createPlaceMark({TEXT:"",POS:e.latLng}))},__point_link_hover:function(){this.style.backgroundColor="#E3E8F7";this.firstChild.style.display="block"},__point_link_hout:function(){this.style.backgroundColor="transparent";this.firstChild.style.display="none"},__createPointView:function(){var e=BX("bx_google_points_"+jsGoogleCE.mapId).appendChild(BX.create("LI",{events:{mouseover:jsGoogleCE.__point_link_hover,mouseout:jsGoogleCE.__point_link_hout},children:[BX.create("A",{attrs:{href:"javascript: void(0)",className:"bx-google-delete"},events:{click:jsGoogleCE.__deletePoint},style:{display:"none"}}),BX.create("A",{attributes:{href:"javascript: void(0)",className:"bx-google-point"},events:{click:jsGoogleCE.__openPointBalloonFromView},html:BX.message("google_noname")})]}));return e},__deletePoint:function(e){BX.PreventDefault(e);var o=this.parentNode;jsGoogleCE.arData.PLACEMARKS[o.BXPlacemark.BX_PLACEMARK_INDEX].DELETED=1;if(o.BXPlacemark.infowin)o.BXPlacemark.infowin=null;o.BXPlacemark.setMap(null);this.parentNode.parentNode.removeChild(this.parentNode)},__updatePointViewText:function(e,o){e.firstChild.nextSibling.innerHTML=o;e.firstChild.nextSibling.style.margin="0 18px 0 0"},__openPointBalloonFromView:function(e){BX.PreventDefault(e);jsGoogleCE.__openBalloon(this.parentNode.BXPlacemark)},__updatePointView:function(e,o){var l=e.value;var a=e.id.substring(18);jsGoogleCE.arData.PLACEMARKS[a].TEXT=l;var t=l.indexOf("\n");var s="";if(l.length>0)s=t<=0?l:l.substring(0,t);s=BX.util.htmlspecialchars(s);var r=document.getElementById("BX_PLACEMARK_"+a);jsGoogleCE.__updatePointViewText(r,s?s:BX.message("google_noname"));if(o=="blur")r.BXPlacemark.infowin.close()},__checkValidKey:function(e){if(Number(e)==e)return true;for(var o=0,l=jsGoogleCE.__arValidKeys.length;o<l;o++){if(jsGoogleCE.__arValidKeys[o]==e)return true}return false},__serialize:function(e){if(typeof e=="object"){var o="",l=0;for(var a in e){if(jsGoogleCE.__checkValidKey(a)){++l;o+=jsGoogleCE.__serialize(a)+jsGoogleCE.__serialize(e[a])}}o="a:"+l+":{"+o+"}";return o}else if(typeof e=="boolean"){return"b:"+(e?1:0)+";"}else if(null==e){return"N;"}else if(Number(e)==e&&e!=""&&e!=" "){if(Math.floor(e)==e)return"i:"+e+";";else return"d:"+e+";"}else if(typeof e=="string"){e=e.replace(/\r\n/g,"\n");e=e.replace(/\n/g,"###RN###");var t=0;if(window._global_BX_UTF){for(var s=0,l=e.length;s<l;s++){if(e.charCodeAt(s)>2047)t+=2;else if(e.charCodeAt(s)>127)t++}}return"s:"+(e.length+t)+':"'+e+'";'}},__saveChanges:function(){if(!jsGoogleCE.map)return false;jsGoogleCE.bAddPointMode=false;if(jsGoogleCE.arData["PLACEMARKS"]){var e=[];for(var o=0,l=jsGoogleCE.arData.PLACEMARKS.length;o<l;o++){if(null==jsGoogleCE.arData.PLACEMARKS[o].DELETED)e[e.length]=jsGoogleCE.arData.PLACEMARKS[o]}jsGoogleCE.arData.PLACEMARKS=e}window.jsGoogleCEOpener.saveData(jsGoogleCE.__serialize(jsGoogleCE.arData),jsGoogleCE.currentView);return false}};var jsGoogleCESearch={bInited:false,map:null,geocoder:null,obInput:null,timerID:null,timerDelay:1e3,arSearchResults:[],obOut:null,__init:function(e){if(jsGoogleCESearch.bInited)return;jsGoogleCESearch.map=jsGoogleCE.map;jsGoogleCESearch.obInput=e;e.form.onsubmit=function(){jsGoogleCESearch.doSearch();return false};e.onfocus=jsGoogleCESearch.showResults;e.onblur=jsGoogleCESearch.hideResults;jsGoogleCESearch.bInited=true},setTypingStarted:function(e){if(!jsGoogleCESearch.bInited)jsGoogleCESearch.__init(e);jsGoogleCESearch.hideResults();if(null!=jsGoogleCESearch.timerID)clearTimeout(jsGoogleCESearch.timerID);jsGoogleCESearch.timerID=setTimeout(jsGoogleCESearch.doSearch,jsGoogleCESearch.timerDelay)},doSearch:function(){var e=jsUtils.trim(jsGoogleCESearch.obInput.value);if(e.length>1){if(null==jsGoogleCESearch.geocoder)jsGoogleCESearch.geocoder=new google.maps.Geocoder;jsGoogleCESearch.geocoder.geocode({address:e,language:BX.message("LANGUAGE_ID")},jsGoogleCESearch.__searchResultsLoad)}},handleError:function(){alert(jsGoogleCE.jsMess.mess_error)},__generateOutput:function(){jsGoogleCESearch.obOut=document.body.appendChild(document.createElement("UL"));jsGoogleCESearch.obOut.className="bx-google-address-search-results";jsGoogleCESearch.obOut.style.display="none"},__searchResultsLoad:function(e,o){var l=jsGoogleCESearch;if(o!=google.maps.GeocoderStatus.OK&&o!=google.maps.GeocoderStatus.ZERO_RESULTS){l.handleError({message:o});return}if(!e){l.handleError()}else{if(null==l.obOut)l.__generateOutput();l.obOut.innerHTML="";l.clearSearchResults();var a=0;if(o==google.maps.GeocoderStatus.OK){a=e.length;var t=null}if(a>0){for(var s=0;s<a;s++){l.arSearchResults[s]=e[s].geometry.location;var r="";for(var n=0;n<e[s].address_components.length;n++){r+=(r.length>0?", ":"")+e[s].address_components[n].long_name}l.obOut.appendChild(BX.create("LI",{attrs:{className:s==0?"bx-google-first":""},children:[BX.create("A",{attrs:{href:"javascript:void(0)"},props:{BXSearchIndex:s},events:{click:l.__showSearchResult},children:[BX.create("SPAN",{text:r})]})]}))}}else{l.obOut.innerHTML='<li class="bx-google-notfound">'+BX.message("google_nothing_found")+"</li>"}l.showResults()}},__showSearchResult:function(e){if(null!==this.BXSearchIndex){jsGoogleCESearch.map.panTo(jsGoogleCESearch.arSearchResults[this.BXSearchIndex])}return BX.PreventDefault(e)},showResults:function(){var e=jsUtils.GetRealPos(jsGoogleCESearch.obInput);jsGoogleCESearch.obOut.style.top=e.bottom+2+"px";jsGoogleCESearch.obOut.style.left=e.left+"px";jsGoogleCESearch.obOut.style.zIndex=parseInt(BX.WindowManager.Get().zIndex)+200;if(BX.findParent(jsGoogleCESearch.obInput,{tag:"div",className:"bx-core-window bx-core-adm-dialog"}).style.display=="block"){if(null!=jsGoogleCESearch.obOut)jsGoogleCESearch.obOut.style.display="block"}},hideResults:function(){if(null!=jsGoogleCESearch.obOut){setTimeout("jsGoogleCESearch.obOut.style.display = 'none'",300)}},clearSearchResults:function(){for(var e=0;e<jsGoogleCESearch.arSearchResults.length;e++){delete jsGoogleCESearch.arSearchResults[e]}jsGoogleCESearch.arSearchResults=[]},clear:function(){if(!jsGoogleCESearch.bInited)return;jsGoogleCESearch.bInited=false;if(null!=jsGoogleCESearch.obOut){jsGoogleCESearch.obOut.parentNode.removeChild(jsGoogleCESearch.obOut);jsGoogleCESearch.obOut=null}jsGoogleCESearch.arSearchResults=[];jsGoogleCESearch.map=null;jsGoogleCESearch.geocoder=null;jsGoogleCESearch.obInput=null;jsGoogleCESearch.timerID=null}};
//# sourceMappingURL=settings_load.map.js